#pragma once

#include "queue"
#include "ClientSender.h"
#include "XmlHandler.h"
#include "UserLogon.h"
#include "XmlIssuerMessageHandler.h"
#include "XmlResponseMessageHandler.h"
using namespace std;

typedef queue<char*> STRINGQUEUE;
class MessageCenter
{ 
	ClientSender* sender;
public:
	STRINGQUEUE* messageQueue;	
	CRITICAL_SECTION csLock;
	DWORD hNotEmpty;

	//note: only support for one socket
	int serverId;
	int mobileId;
	int socketId;
	UserLogon* userLogon;
public:
	MessageCenter(UserLogon*);
	~MessageCenter(void);
	void enqueueMessage(char* message);
	void start();
	void sendMessage(char* message, int desId);
	void addClientSender(ClientSender* sender);
private:
	static void handleMessage(MessageCenter* mCenter);
	void handleIssuerMessage(XmlIssuerMessageHandler* xml);
	void handleResponseMessage(XmlResponseMessageHandler* xml);
};
